﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DevToolBox.Cloud.Common
{
    /// <summary>
    /// Imterface to abstract the execution of ad-hoc like commands
    /// against a third party/cloud service persistance provider
    /// </summary>
    public interface ITableCommand
    {
        /// <summary>
        /// Adds an item to the underlaying persistance provider
        /// </summary>
        /// <param name="item">Objec to save</param>
        /// <returns>Third party provider/service response</returns>
        object Put(object item);

        /// <summary>
        /// Scans a persistance provider
        /// </summary>
        /// <param name="tableName">Table Name</param>
        /// <param name="rangeName">Secondary key name</param>
        /// <param name="rangeValue">Secondary Key value</param>
        /// <param name="oper">Operator to apply in the main/primary key</param>
        /// <param name="lastHashValue">Last primary/main key known value</param>
        /// <param name="lastRangeValue">Last secondary key known value</param>
        /// <returns>Object-plain response</returns>
        /// <remarks>
        /// This is method is used with an IParseable instance to
        /// convert the values into the expected data type
        /// </remarks>
        object ExecuteScan(string tableName, string rangeName, string rangeValue, 
                           string oper, string lastHashValue, string lastRangeValue);

        /// <summary>
        /// Method to query a persistance provider
        /// </summary>
        /// <param name="tableName">Table Name</param>
        /// <param name="hashValue">Primary/main key value</param>
        /// <param name="lastHashValue">Last primary/main key known value</param>
        /// <param name="lastRangeValue">Last secondary key known value</param>
        /// <param name="recordCount">Quantity of records to retrieve</param>
        /// <returns>Object-plain response</returns>
        /// <remarks>
        /// This is method is used with an IParseable instance to
        /// convert the values into the expected data type
        /// </remarks>
        object ExecuteQuery(string tableName, string hashValue, string lastHashValue, 
                            string lastRangeValue, int recordCount);

        /// <summary>
        ///  Method to query a persistance provider
        /// </summary>
        /// <param name="tableName">Table Name</param>
        /// <param name="hashValue">Primary/main key value</param>
        /// <param name="hashRange">Secondary Key value</param>
        /// <param name="rangeOperator">Operator to apply in the secondary key</param>
        /// <param name="lastHashValue">Last primary/main key known value</param>
        /// <param name="lastRangeValue">Last secondary key known value</param>
        /// <param name="recordCount">Quantity of records to retrieve</param>
        /// <returns>Object-plain response</returns>
        /// <remarks>
        /// This is method is used with an IParseable instance to
        /// convert the values into the expected data type
        /// </remarks>
        object ExecuteQuery(string tableName, string hashValue, string hashRange,
                            string rangeOperator, string lastHashValue, string lastRangeValue, 
                            int recordCount);

        /// <summary>
        /// Method to query a persistance provider
        /// </summary>
        /// <param name="tableName">Table Name</param>
        /// <param name="hashValue">Primary/main key value</param>
        /// <param name="hashRange">Secondary Key value</param>
        /// <param name="rangeOperator">Operator to apply in the secondary key</param>
        /// <param name="lastHashValue">Last primary/main key known value</param>
        /// <param name="lastRangeValue">Last secondary key known value</param>
        /// <param name="recordCount">Quantity of records to retrieve</param>
        /// <returns>Object-plain response</returns>
        /// <remarks>
        /// This is method is used with an IParseable instance to
        /// convert the values into the expected data type
        /// </remarks>
        object ExecuteQuery(string tableName, int hashValue, int hashRange,
                            string rangeOperator, string lastHashValue, string lastRangeValue, 
                            int recordCount);

        void Save(List<RowEntity> entities);

        void Save(RowEntity entity);

    }
}
